<?php

namespace modules\point\controller;

use OpenApi\Attributes as OA;

#[OA\Tag(name: '积分', description: '积分接口')]
class ApiController extends \core\ApiController
{
    protected $model = [
        'point' => "\modules\point\model\PointModel",
        'point_his' => "\modules\point\model\PointHisModel",
    ];
    /**
     * 积分总数
     */
    #[OA\Get(
        path: '/point/api/total',
        summary: '获取积分总数',
        tags: ['积分'],
    )]
    public function actionTotal()
    {
        $find = $this->model->point->findOne(['user_id' => $this->user_id]);
        json_success(['data' => $find['point'] ?: 0]);
    }
    /**
     * 积分列表 
     */
    #[OA\Get(
        path: '/point/api/index',
        summary: '获取积分列表',
        tags: ['积分'],
    )]
    public function actionIndex() {
        $where = [];
        $where['user_id'] = $this->user_id;
        $where['ORDER'] = ['id' => 'DESC'];
        $list = $this->model->point_his->pager($where);
        json($list);
    }
 
}
